import { createRouter, createWebHashHistory, RouteRecordRaw } from 'vue-router'
import Layout from '../views/layout/index.vue';
export const constantRoutes: Array<RouteRecordRaw> = [
  {
    path: '/redirect',
    component: Layout,
    meta: {
      hidden: true
    },
    children: [
      {
        path: '/redirect/:path(.*)',
        component: () => import('@/views/redirect.vue')
      }
    ]
  },
  {
    path: '/',
    name: 'Layout',
    component: Layout,
    redirect: 'index',
    meta: {
      title: "首页",
      hidden: true,
      roles: ['admin']
    },
    children: [
      {
        path: '/index',
        name: 'index',
        component: () => import('@/views/index/index.vue'),
        meta: {
          title: '欢迎',
          icon: 'iconfont icon-shouye',
          isRoot: true,
          isAffix: true
        }
      }
    ]
  },
  {
    path: '/login',
    name: 'Login',
    component: () => import('@/views/login/login.vue'),
    meta: {
      hidden: true
    }
  },
  {
    path: '/system',
    name: 'System',
    redirect: '/system/user',
    component: Layout,
    meta: {
      title: '基础信息',
      icon: 'el-icon-setting'
    },
    children: [
      {
        path: 'dept',
        name: 'DeptInfo',
        component: () => import('@/views/system/dept/index.vue'),
        meta: {
          title: '部门管理',
          icon: 'el-icon-office-building',
          roles: ['admin']
        }
      },
      {
        path: 'staff',
        name: 'StaffInfo',
        component: () => import('@/views/system/staff/index.vue'),
        meta: {
          title: '员工管理',
          icon: 'el-icon-user',
          roles: ['admin']
        }
      },
      {
        path: 'role',
        name: 'UserRole',
        component: () => import('@/views/system/role/index.vue'),
        meta: {
          title: '用户角色',
          icon: 'el-icon-user-solid',
          roles: ['admin'],
          hidden: true
        }
      }
    ]
  },
  {
    path: '/wage',
    name: 'Wage',
    redirect: '/wage/index',
    component: Layout,
    meta: {
      title: '工资绩效',
      icon: 'el-icon-s-operation'
    },
    children: [
      {
        path: 'index',
        name: 'WageIndex',
        component: () => import('@/views/wage/index.vue'),
        meta: {
          title: '工资绩效',
          icon: 'el-icon-office-building',
          roles: ['admin'],          
          hidden: true
        }
      },
      {
        path: 'dept',
        name: 'DeptWage',
        component: () => import('@/views/wage/dept/index.vue'),
        meta: {
          title: '部门绩效',
          icon: 'el-icon-office-building',
          roles: ['admin']
        }
      },
      {
        path: 'staff',
        name: 'StaffWage',
        component: () => import('@/views/wage/staff/index.vue'),
        meta: {
          title: '员工工资',
          icon: 'el-icon-s-custom',
          roles: ['admin']
        }
      }
    ]
  },
  {
    path: '/task',
    name: 'Task',
    redirect: '/task/intro',
    component: Layout,
    meta: {
      title: '绩效工资',
      icon: 'el-icon-collection-tag',
      roles: ['clerk']
    },
    children: [
      {
        path: 'intro',
        name: 'SalaryIntro',
        component: () => import('@/views/task/intro/index.vue'),
        meta: {
          title: '工资构成',
          icon: 'el-icon-paperclip',
          hidden: true
        }
      },
      {
        path: 'admin',
        name: 'SalaryAdmin',
        component: () => import('@/views/task/admin/index.vue'),
        meta: {
          title: '工资任务',
          icon: 'el-icon-coordinate',
          roles: ['admin']
        }
      },
      {
        path: 'createTask',
        name: 'TaskCreate',
        component: () => import('@/views/task/admin/create.vue'),
        meta: {
          title: '创建工资任务',
          icon: 'el-icon-coordinate',
          roles: ['admin'],
          hidden: true
        }
      },
      {
        path: 'wage/:id',
        name: 'SalaryWage',
        component: () => import('@/views/task/dept/wage.vue'),
        meta: {
          title: '工资详情',
          icon: 'el-icon-user',
          roles: ['admin'],
          hidden: true
        }
      },
      {
        path: 'merit',
        name: 'SalaryMerit',
        component: () => import('@/views/task/merit/index.vue'),
        meta: {
          title: '员工绩效',
          icon: 'el-icon-connection',
          roles: ['clerk']
        }
      },
      {
        path: 'merit/task/:id',
        name: 'MeritTask',
        component: () => import('@/views/task/merit/staff.vue'),
        meta: {
          title: '绩效详情',
          icon: 'el-icon-connection',
          roles: ['clerk', 'editor'],
          hidden: true
        }
      },
      {
        path: 'cadre/task',
        name: 'CadreMerit',
        component: () => import('@/views/task/merit/cadre.vue'),
        meta: {
          title: '干部绩效',
          icon: 'el-icon-bank-card',
          roles: ['admin']
        }
      },
      {
        path: 'account',
        name: 'SalaryAccount',
        component: () => import('@/views/task/account/index.vue'),
        meta: {
          title: '数据查看',
          icon: 'el-icon-document-checked',
          roles: ['editor']
        }
      },
    ]
  },
  {
    path: '/my',
    name: 'My',
    redirect: '/my/index',
    component: Layout,
    meta: {
      title: '个人设置',
      icon: 'el-icon-edit-outline'
    },
    children: [
      {
        path: 'index',
        name: 'MyIndex',
        component: () => import('@/views/my/index.vue'),
        meta: {
          title: '个人介绍',
          icon: 'el-icon-news',
          hidden: true
        }
      },
      {
        path: 'pwd',
        name: 'Pwd',
        component: () => import('@/views/my/pwd/index.vue'),
        meta: {
          title: "修改密码",
          icon: 'el-icon-key'
        }
      }
    ]
  },
  {
    path: '/content',
    name: 'Content',
    redirect: '/content/notice',
    component: Layout,
    meta: {
      title: '内容管理',
      icon: 'el-icon-school',
      hidden: true
    },
    children: [
      {
        path: 'notice',
        name: 'Notice',
        component: () => import('@/views/content/notice/index.vue'),
        meta: {
          title: '新闻管理',
          icon: 'el-icon-news'
        }
      },
      {
        path: 'room',
        name: 'Room',
        component: () => import('@/views/content/room/index.vue'),
        meta: {
          title: "会议室管理",
          icon: 'el-icon-data-board'
        }
      }
    ]
  }
  // {
  //   path:'/layout',
  //   name: 'Layout',
  //   component:()=> import('@/views/layout/index.vue')
  // }
]
const router = createRouter({
  history: createWebHashHistory(),
  routes: constantRoutes
})

export default router
